//mongodb node的驱动程序
const mongoose = require("mongoose");
//引入 执行model
require("../db/model/carts");
//初始化数据(生成商品大类导航)
const carts = [
  {
    detail: [{ commodityId: "619de719fa6831aa599d63df" }],
  },
  {
    detail: [
      { commodityId: "619de719fa6831aa599d63df" },
      { commodityId: "619de719fa6831aa599d63df" },
    ],
  },
];
//建立连接
mongoose.connect(
  "mongodb://tangzhenhua:Lovo123456@182.92.214.223:8084/maiwenjie-project",
  {
    useNewUrlParser: true,
    useUnifiedTopology: true,
    auth: { authSource: "admin" },
  },
  async () => {
    const cartsModel = mongoose.model("carts"); //创建model
    const data = await cartsModel.create(carts); //调用create方法
    console.log(data);
  }
);
